package com.chen.util;

import com.chen.exception.BusinessException;

import java.util.Collection;
import java.util.Map;

public class Check {
    public static void checkParameter(Object... objects) {
        if (objects == null || objects.length == 0) {
            throw new BusinessException(204,"参数不能为空");
        }
        for (Object obj : objects) {
            if (obj == null) {
                throw new BusinessException(204, "参数中存在空值");
            }
            if (obj instanceof String && ((String) obj).trim().isEmpty()) {
                throw new BusinessException(204, "字符串参数不能为空");
            }
            if (obj instanceof Collection && ((Collection<?>) obj).isEmpty()) {
                throw new BusinessException(204, "集合参数不能为空");
            }
            if (obj instanceof Map && ((Map<?, ?>) obj).isEmpty()) {
                throw new BusinessException(204, "Map 参数不能为空");
            }
        }
    }
}
